const path = require('path');
const HtmlWebPackPlugin = require("html-webpack-plugin");
module.exports = {
  entry: "./src/utils/register-wc.js",
  output: {
      library: { name: "ReactWebComponents", type: "umd" },
      filename: "react-web-components.js",
      path: path.resolve(__dirname, "dist"),
      clean: true,
  },
  resolve: {
    extensions: [".js", ".jsx"],
    alias: {
      '@': path.resolve(__dirname, 'src')
    },
  },
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader'
        }
      },
      {
        test: /\.html$/,
        use: {
          loader: 'html-loader'
        }
      },
      {
        test: /\.css$/,
        oneOf: [
          {
            resourceQuery: /inline/,
            use: [
              {
                loader: 'css-loader',
                options: {
                  exportType: 'string'
                }
              }
            ]
          },
          {
            use: [/*'style-loader',*/ 'css-loader']
          }
        ]
      },
      {
        test: /\.less$/,
        oneOf: [
          {
            resourceQuery: /inline/,
            use: [
              {
                loader: 'css-loader',
                options: {
                  exportType: 'string'
                }
              },
              "less-loader"
            ]
          },
          {
            use: [
              // 'style-loader',
              'css-loader',
              'less-loader'
            ]
          }
        ]
      }
    ],
  },
  plugins: [
    new HtmlWebPackPlugin({
      title: 'react app',
      filename: 'index.html',
      template: './public/index.html'
    })
  ]
};